// components/common/sns-show-item/index.js
import componentBehavior from '../../../behaviors/component';
import { COMPONENT_OPTIONS, SNS_TYPE_ENUM } from '../../../constants/common';
import { navToMiniProgram, previewImage } from '../../../common/env';

Component({
    behaviors: [componentBehavior],
    options: {
        ...COMPONENT_OPTIONS,
    },
    properties: {
        snsInfo: {
            type: Object,
            value: {},
        },
        isShort: {
            type: Boolean,
            value: false,
        },
    },
    data: {
        SNS_TYPE_ENUM,
    },
    methods: {
        handleClick() {
            const { snsInfo, cosConf } = this.data;
            const { viewType, appId, path, qrCode } = snsInfo;
            if (viewType === 'path') {
                navToMiniProgram(appId, path);
            } else {
                previewImage(`${cosConf.path}/${qrCode}`);
            }
            this.triggerEvent('click', snsInfo);
        },
    }
})
